﻿using System.Drawing;
using System.Windows.Forms;
using AiFrame.Interface.WinUI.Windows.Controls;
using AiFrame.InterfaceLib.MVP;
using AiFrame.InterfaceLib.Windows.Themes;

namespace AiFrame.Interface.WinUI.Windows.UI
{
    /// <summary>
    /// Stellt ein abstraktes Frame dar, welches einen Header besitzt.
    /// </summary>
    public partial class AbstractFrame : UserControl, IAbstractWindow
    {
        protected GradientPanel _topPanel;
        private IStyleGuideUI _styleGuide;
        private ITheme _theme;
        private Image _image;
        private Image _backgroundImage;

        public AbstractFrame()
        {
            InitializeComponent();
            
        }

        protected void InitializeAbstractFrame(IStyleGuideUI styleGuideUI, ITheme theme, Image headerImage)
        {
            _styleGuide = styleGuideUI;
            _theme = theme;
            _image = headerImage;
            _backgroundImage = theme.GetDataWindowBgLogo();

            if (_image == null)
            {
                _image = _theme.GetListHeaderIcon();
            }


            _topPanel = new GradientPanel()
            {
                Parent = this,
                Dock = DockStyle.Top,
                Height = 70,
                GradientStartColor = _theme.GetPanelBeginColor(),
                GradientEndColor = _theme.GetPanelEndColor()
            };
            _topPanel.Paint += new PaintEventHandler(backPanel_Paint);
        }

        private void backPanel_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawImage(_backgroundImage,
                    _topPanel.Width - _backgroundImage.Width,
                    0,
                    _backgroundImage.Width,
                    _topPanel.Height);
            e.Graphics.DrawImage(_image, _topPanel.Width - 70,
                    18, _image.Width, _image.Height);

            e.Graphics.DrawString(GetCaption(), _theme.GetMainHeaderFont(),
                new SolidBrush(_theme.GetMainHeaderFontColor()),
                20, 13);
            e.Graphics.DrawString("Benutzen Sie die Filterfunktionen, um die Listenansicht einzuschränken.",
                    new Font("Microsoft Sans Serif", 8, FontStyle.Regular), new SolidBrush(Color.FromArgb(100, 100, 100)),
                    20, 38);
        }

        public virtual string GetCaption()
        {
            return "Window";
        }

        public virtual void RefreshView()
        {
            throw new System.NotImplementedException();
        }

        public void SetFree()
        {
            throw new System.NotImplementedException();
        }

        public void SetParentWindow(Control parent)
        {
            Parent = parent;
        }

        public virtual void BringWindowToFront()
        {
            BringToFront();
        }
    }
}
